package leetcode_cn;

/**
 * 盛最多水的容器
 *
 * @author briarbear
 * @blog https://briarbear.github.io
 * @date 2018-09-06 15:49
 */
public class MaxArea {


    public int solution(int[] height){
        if (height == null || height.length == 0) return 0;
        int len = height.length;
        int left = 0,right = len-1,res = 0;
        while (left < right){
            int temp = (right - left) * Math.min(height[left],height[right]);
            if (temp > res) res = temp;
            if (height[left] < height[right]) left++;
            else right--;
        }

        return res;
    }
}
